/* flatpickr v4.6.13 CDN Loader */
(function (root, factory) {
    // 直接执行工厂函数，不使用模块系统
    factory(root);
}(typeof self !== 'undefined' ? self : this, function (root) {
    // 如果flatpickr已经加载，直接返回
    if (root && typeof root.flatpickr !== 'undefined') {
        return;
    }

    // 动态加载flatpickr CSS
    var css = document.createElement('link');
    css.rel = 'stylesheet';
    css.href = 'https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.6.13/flatpickr.min.css';
    document.head.appendChild(css);

    // 临时禁用define函数，避免CDN脚本的匿名define冲突
    var originalDefine = root.define;
    root.define = undefined;

    // 动态加载flatpickr JS
    var script = document.createElement('script');
    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.6.13/flatpickr.min.js';
    script.onload = function() {
        // 恢复define函数
        root.define = originalDefine;

        // 触发自定义事件表示flatpickr加载完成
        if (typeof root.CustomEvent === 'function') {
            root.dispatchEvent(new root.CustomEvent('flatpickrLoaded'));
        }
    };
    script.onerror = function() {
        // 恢复define函数
        root.define = originalDefine;
    };
    document.head.appendChild(script);
}));